package advance.homework;

/**
 * 将字符串的指定部分进行反转
 * @author Raymond
 * @create 2025/4/23 15:55
 */
public class MyStringExc {
    public static void main(String[] args) {
        String str = "abcdef";
        System.out.println(reverse(str, 2, 3));
    }

    public static String reverse(String str,int start,int end){
        char[] charArray = str.toCharArray();
        for (int i = start,j=end; i < j; i++,j--) {
            char temp =  charArray[i];
            charArray[i]  =charArray[j];
            charArray[j] = temp;
        }
        return new String(charArray);
    }
}
